package mygang.dao.manager;

import java.util.List;
import mygang.model.Role;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

/**
 *
 * @author Volodymyr Lavrynovych <volodya.lavrynovych@gmail.com>
 */
@Repository("roleDAO")
@Transactional
public class RoleDAOImpl extends AbstractManageDAO<Role> implements RoleDAO {
    
    private static final Logger log = Logger.getLogger(RoleDAOImpl.class.toString());
    
    public Role findByName(String roleName) {
        List<Role> roles = getHibernateTemplate().find("from Role r where r.name = ?", roleName);
        return !roles.isEmpty() ? roles.get(0) : new Role();
    }
}